#include "HexaTile.h"

using namespace Game;

int HexaTile::ColoredBlue;
int HexaTile::ColoredGreen;

HexaTile::HexaTile()
{
	mIsShiny=false;
	mIsBlue=false;
	mIsGreen=false;
	mNumber=-1;
	ColoredGreen=0;
	ColoredBlue=0;
	mColor=Hexa::NORMAL;
	//mNumImage= GraphicsUtil::getInstance().Create_SDLSurface("resources\\images\\n6.png",1,1,1);
}

HexaTile::~HexaTile()
{
	//
}

void HexaTile::setNumber(unsigned int number) 
{
	mNumber=number;
}

void HexaTile::setIndex(unsigned int index) 
{
	mIndex=index;
}


void HexaTile::setColor(unsigned int color,bool forced) 
{
	if(mColor==Hexa::BLUE || mColor==Hexa::GREEN)
	{
		if(!forced)
			return;
	}
	mColor=color;
	if(color==Hexa::SHINY)
	{
		mImageNow=mImageShiny;
	}
	else if(color==Hexa::NORMAL)
	{
		mImageNow=mImage;
	}
	else if(color==Hexa::BLUE)
	{
		mImageNow=mImageBlue;
		++ColoredBlue;
	}
	else if(color==Hexa::GREEN)
	{
		mImageNow=mImageGreen;
		++ColoredGreen;
	}
}

void HexaTile::setPos(unsigned int xValue,unsigned int yValue) 
{
	mPosX=xValue;
	mPosY=yValue;
}

int HexaTile::getNumber()
{
	return mNumber;
}

unsigned int HexaTile::getIndex()
{
	return mIndex;
}

unsigned int HexaTile::getColor()
{
	return mColor;
}

unsigned int HexaTile::getPosX()
{
	return mPosX;
}

unsigned int HexaTile::getPosY()
{
	return mPosY;
}

void HexaTile::setSDLSurface(SDL_Surface& image,SDL_Surface& imageShiny,SDL_Surface& imageBlue,SDL_Surface& imageGreen,SDL_Surface& display)
{
	mImage=&image;
	mImageShiny=&imageShiny;
	mImageBlue=&imageBlue;
	mImageGreen=&imageGreen;
	mDisplay=&display;

	mImageNow=mImage;
}

void HexaTile::Render()
{
	GraphicsUtil::getInstance().Render_SDLSurface(mDisplay,mImageNow, mPosX,mPosY);
	if(mNumber>(-1))
	{
		GraphicsUtil::getInstance().DrawNumber(mDisplay,mNumber,mPosX+32,mPosY+32);
	}

}